
#pragma once


class Image
{
public:
    Image();
    ~Image();

    void load(const char * path);
    void load(const unsigned char * buffer, long len);

    const unsigned char * data() { return (unsigned char*) mImageBuffer; }
    operator const unsigned char *() { return data(); }
    int size() { return mImageBufferLength; }
    int width() { return mWidth; }
    int height() { return mHeight; }
    int depth() { return mDepth; }

private:
    char *  mImageBuffer;
    int     mImageBufferLength;
    int     mWidth;
    int     mHeight;
    int     mDepth;

    void clear();
    char* assign(int len);
    void loadpng(const unsigned char * buffer, long len);
    void loadjpg(const unsigned char * buffer, long len);
    void loadbmp(const unsigned char * buffer, long len);
};

